<template>
  <aside class="btn-box">
    <el-row type="flex" :gutter="15">
      <el-col :span="2">
        <el-button type="primary" icon="el-icon-circle-plus-outline" size="mini" @click="addNewStorehouse">新增</el-button>
        <storehouse-form ref="storehouseForm" @reloadData="reloadFun" />
      </el-col>
      <el-col :span="2">
        <el-button type="primary" icon="el-icon-download" size="mini" @click="downloadFun">导出</el-button>
      </el-col>
      <el-col :span="2">
        <el-button type="primary" icon="el-icon-search" size="mini" @click="searchBtn">检索</el-button>
        <storehouse-search ref="search" :warehouse-list="warehouseList" @searchFun="searchFun" />
      </el-col>
    </el-row>
  </aside>
</template>

<script>
import storehouseForm from './storehouse-form'
import storehouseSearch from './storehouse-search'
export default {
  components: {
    storehouseForm,
    storehouseSearch
  },
  props: {
    warehouseList: {
      type: Array,
      default() {
        return []
      }
    }
  },
  data() {
    return {
      warehouseInfoForm: {
        warehouseId: '',
        company: '',
        place: '',
        address: '',
        desc: ''
      },
      rules: {
        warehouseId: [
          { required: true, message: '请输入仓库编号', trigger: 'blur' }
        ]
      },
      form: {
        name: ''
      },
      dialogFormVisible: false,
      formLabelWidth: '80px',
      dialogAddNew: false
    }
  },
  methods: {
    addNewStorehouse() {
      this.$refs.storehouseForm.dialogAddNew = true
      // this.$refs.storehouseForm.warehouseList = this.warehouseList
    },
    downloadFun() {
      this.$emit('downloadFun')
    },
    searchBtn() {
      this.$refs.search.storehouseSearch = true
    },
    searchFun(val) {
      // console.log(val)
      this.$emit('searchFun', val)
    },
    reloadFun() {
      this.$emit('reloadFun')
    }
  }
}
</script>

<style lang="scss" scoped>
  .btn-box {
      width: 100%;
      padding:10px;
      box-sizing: border-box;
      border-radius: 5px;
  }
  .el-button {
    width: 100%;
  }
</style>
